package org.deri.socializer.activities.map;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;

public class DisplayDimensions {

	float minLat;
	float maxLat;
	float minLng;
	float maxLng;
	
	public DisplayDimensions(float minLat, float maxLat, float minLng, float maxLng) {
		this.minLat = minLat;
		this.maxLat = maxLat;
		this.minLng = minLng;
		this.maxLng = maxLng;
	}

	public float getMinLat() {
		return minLat;
	}

	public float getMaxLat() {
		return maxLat;
	}

	public float getMinLng() {
		return minLng;
	}

	public float getMaxLng() {
		return maxLng;
	}
	
	
	
	public static DisplayDimensions getDisplayDimensions(MapView mapView) {
		GeoPoint center = mapView.getMapCenter();
		int latitudeSpan = mapView.getLatitudeSpan();
		int longitudeSpan = mapView.getLongitudeSpan();
		
		float minLat = center.getLatitudeE6() - Math.round(latitudeSpan / 2);
		float maxLat = center.getLatitudeE6() + Math.round(latitudeSpan / 2);
		float minLng = center.getLongitudeE6() - Math.round(longitudeSpan / 2);
		float maxLng = center.getLongitudeE6() + Math.round(longitudeSpan / 2);
		
		return new DisplayDimensions(minLat/1000000, maxLat/1000000, minLng/1000000, maxLng/1000000);
	}
	
}
